<template>
  <div class="app-container">
    <div class="searchBox">
      <el-form :inline="true">
        <el-form-item label="系统类型：">
          <el-select v-model="search.osName">
            <el-option value>请选择</el-option>
            <el-option
              :key="item.key"
              v-for="item in controlData.pkgOsTypeOptions"
              :value="item.value"
              :label="item.key"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="searchQuery">查询</el-button>
          <el-button type="info" @click="search = {}; searchQuery();">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <qm-table
      ref="qmTable"
      :data="query"
      keyProp="publishId"
      :formValidate="defaultFormValidate"
      isCustomForm
      :showView="false"
    >
      <qm-table-column style="width: 50px;" field="appName" sortable="true">app名称</qm-table-column>
      <qm-table-column style="width: 50px;" field="osName" sortable="true">系统类型</qm-table-column>
      <qm-table-column style="width: 50px;" field="version" sortable="true">版本</qm-table-column>
      <qm-table-column
        style="width: 50px;"
        field="updateType"
        width="100px"
        sortable="true"
        :renderFunc="formatUpdateType"
      >更新方式</qm-table-column>
      <qm-table-column style="width: 80px;" field="note" sortable="true" show-overflow>更新说明</qm-table-column>

      <template v-slot:form="{ models, controlData, pageAction }">
        <create ref="create" :models="models" :controlData="controlData" :pageAction="pageAction"></create>
      </template>
    </qm-table>
  </div>
</template>

<script>
import Controller from "@/libs/framework/controller";
import Create from "./create";
export default class Instance extends Controller {
  onBeforeInit() {
    this.urls = {
      model: "/mobile/mobileAppPublish/getListModel",
      query: "/mobile/mobileAppPublish/query",
      save: "/mobile/mobileAppPublish/save",
      delete: "/mobile/mobileAppPublish/delete",
      entity: "/mobile/mobileAppPublish/getEntity",
    };
  }

  showLoading() {
    return false;
  }

  onBeforeQuery(type, conditions, params) {
    if (type === "list") {
      this.$util.extend(params.query, { appId: this.vm.appId });
    }
  }

  onBeforeGetEntity(params) {
    if (params && params.pageAction === "create") {
      params.appId = this.vm.appId;
    }
  }

  mixin() {
    return {
      components: {
        Create,
      },
      props: {
        appId: String,
      },
      data() {
        return {};
      },
      methods: {
        formatUpdateType(cell, type, row) {
          let item = this.super.$util.find(this.controlData.updateTypeOptions, {
            value: cell,
          });
          return item ? item.key : "";
        },
      },
    };
  }
}
</script>

<style scoped lang="scss">
</style>
